package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Movies2;
import com.ruoyi.system.service.IMovies2Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电影信息Controller
 * 
 * @author yhd-csq
 * @date 2024-06-05
 */
@RestController
@RequestMapping("/system/movies2")
public class Movies2Controller extends BaseController
{
    @Autowired
    private IMovies2Service movies2Service;

    /**
     * 查询电影信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:movies2:list')")
    @GetMapping("/list")
    public TableDataInfo list(Movies2 movies2)
    {
        startPage();
        List<Movies2> list = movies2Service.selectMovies2List(movies2);
        return getDataTable(list);
    }

    /**
     * 导出电影信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:movies2:export')")
    @Log(title = "电影信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Movies2 movies2)
    {
        List<Movies2> list = movies2Service.selectMovies2List(movies2);
        ExcelUtil<Movies2> util = new ExcelUtil<Movies2>(Movies2.class);
        util.exportExcel(response, list, "电影信息数据");
    }

    /**
     * 获取电影信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:movies2:query')")
    @GetMapping(value = "/{movieName}")
    public AjaxResult getInfo(@PathVariable("movieName") String movieName)
    {
        return success(movies2Service.selectMovies2ByMovieName(movieName));
    }

    /**
     * 新增电影信息
     */
    @PreAuthorize("@ss.hasPermi('system:movies2:add')")
    @Log(title = "电影信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Movies2 movies2)
    {
        return toAjax(movies2Service.insertMovies2(movies2));
    }

    /**
     * 修改电影信息
     */
    @PreAuthorize("@ss.hasPermi('system:movies2:edit')")
    @Log(title = "电影信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Movies2 movies2)
    {
        return toAjax(movies2Service.updateMovies2(movies2));
    }

    /**
     * 删除电影信息
     */
    @PreAuthorize("@ss.hasPermi('system:movies2:remove')")
    @Log(title = "电影信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{movieNames}")
    public AjaxResult remove(@PathVariable String[] movieNames)
    {
        return toAjax(movies2Service.deleteMovies2ByMovieNames(movieNames));
    }
}
